package com.fairytask.ui.item
{
	import com.fairytask.engine.components.BaseItem;
	import com.fairytask.engine.components.clip.Clip;
	import com.fairytask.engine.components.text.Label;
	import com.fairytask.engine.define.ResConfig;
	
	/**
	 * 技能物件 
	 * @author xujh
	 * 
	 */
	public class SkillItem extends BaseItem
	{
		private var _bgPhoto	:Clip;
		private var _label		:Label;
		private var _source	:String;
		private var _skillId	:String;
		private var _lock		:Clip;;
		private var _pos		:int;
		public function SkillItem()
		{
			_bgPhoto = new Clip();
			_label	= new Label();
			_bgPhoto.x=2;
			_bgPhoto.y=2;
			_label.y = 32;
			addChild(_bgPhoto);
			addChild(_label);
		}
		
		public function get level():int
		{
			return int(_label.htmlStr);
		}
		
		public function set level(val:int):void
		{
			if(val>9)
			{
				_label.x = 32;
			}
			else
			{
				_label.x = 36;
			}
			_label.htmlStrByBorder = String(val);
		}
		public function get source():String
		{
			return _source;
		}
		
		public function set source(value:String):void
		{
			//有图就清除锁
			if(null!=_lock)
			{
				if(contains(_lock))
				{
					removeChild(_lock);
				}
			}
			_source = value;
			_bgPhoto.source	=	value;
			_bgPhoto.y = 3;
			_bgPhoto.width = 50;
			_bgPhoto.height = 50;
		}
		
		public function get pos():int
		{
			return _pos;
		}
		
		public function set pos(val:int):void
		{
			_pos = val;
		}
		
		public function get skillId():String
		{
			return _skillId;
		}
		
		public function set skillId(value:String):void
		{
			_skillId = value;
		}
		
		/**
		 * 加锁 
		 * @param value
		 * 
		 */
		public function set lockSkill(	value:Boolean	):void
		{
			if(value)
			{
				//已经加锁，返回
				if(_lock == null)
				{
					_lock = new Clip;
					_lock.source = ResConfig.pngResPath + "locked.png";
					_lock.x	=	-5;
					_lock.y	=	-8;
				}
				addChild(_lock);
			}
			else
			{
				//去锁
				if(contains(_lock))
				{
					removeChild(_lock);
				}
			}
		}
		
		/**
		 * 清除图片及数量
		 * 
		 */
		public function clearPhoto():void
		{
			_bgPhoto.clear();
			_label.htmlStr = "";
		}
		
	}
}